:root {
    --wc-modal-z-index: 10000;
    --wc-modal-textbox-width: 75%;
    --wc-modal-sidebar-width: 25%;
    --wc-modal-animation-duration: 0.15s;
    --wc-modal-animation-duration-long: 0.3s;
    --wc-modal-animation-timing: cubic-bezier(.25,.8,.25,1);
}

#wildcard-selector-composer-v2-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--wc-modal-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--wc-modal-animation-duration) ease forwards;
}

#wildcard-selector-composer-v2-modal {
    width: 80vw;
    height: 85vh;
    z-index: calc(var(--wc-modal-z-index) + 1);
    display: flex;
    overflow: hidden;
}

#wildcard-selector-composer-v2-modal > .sidebar {
    width: var(--wc-modal-sidebar-width);
    height: calc(100% - 2rem);
    margin: 1rem 0;
    background: rgb(30, 30, 30);
    transform: scaleX(0);
    transform-origin: left center;
    position: relative;
    transition: width var(--wc-modal-animation-duration-long) ease var(--wc-modal-animation-duration),
                transform var(--wc-modal-animation-duration) ease calc(var(--wc-modal-animation-duration-long) + var(--wc-modal-animation-duration));
    box-shadow: inset 8px 0 16px -8px rgba(0,0,0,0.55);
    display: flex;
    flex-direction: column;
}

#wildcard-selector-composer-v2-modal > .sidebar .topbar {
    width: 100%;
    height: 2.5rem;
    background: rgb(20, 20, 20);
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px 0 rgba(0,0,0,0.35);
    flex: 0 0 2.5rem;
    position: relative;
}

.sidebar > .wildcard-dropdown-container {
    width: 95%;
    margin: 0 auto 8px auto;
    max-height: calc(100% - 2.5rem);
    overflow-y: auto;
    overflow-x: hidden;
}

.wildcard-dropdown-container {
    width: 100%;
    margin: 0 0 8px 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.custom-dropdown {
    width: 100%;
    position: relative;
    min-width: 0;
    margin-bottom: 0;
    transition: height 0.25s cubic-bezier(.25,.8,.25,1);
    overflow: visible;
}

#wildcard-selector-composer-v2-modal > .textbox {
    width: var(--wc-modal-textbox-width);
    background: rgb(25, 25, 25);
    position: relative;
    transition: width var(--wc-modal-animation-duration-long) ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#wildcard-selector-composer-v2-modal > .textbox .topbar {
    padding: 0.5rem 1rem;
    text-align: left;
}

#wildcard-selector-composer-v2-modal:not(.closing) > .textbox {
    opacity: 0;
    animation: fadeIn var(--wc-modal-animation-duration) var(--wc-modal-animation-timing) forwards;
}

#wildcard-selector-composer-v2-modal:not(.sidebar-hidden) > .sidebar {
    animation: growWidth var(--wc-modal-animation-duration) var(--wc-modal-animation-timing) var(--wc-modal-animation-duration) forwards;
}

#wildcard-selector-composer-v2-modal.sidebar-hidden > .sidebar {
    width: 0%;
    transform: scaleX(0);
    transition: width var(--wc-modal-animation-duration) ease,
                transform var(--wc-modal-animation-duration-long) ease;
}

#wildcard-selector-composer-v2-modal.sidebar-hidden > .textbox {
    width: 100%;
    transition: width var(--wc-modal-animation-duration-long) ease var(--wc-modal-animation-duration);
}

#wildcard-selector-composer-v2-modal.sidebar-animating-out > .sidebar {
    animation: shrinkWidth var(--wc-modal-animation-duration) var(--wc-modal-animation-timing) forwards;
}

#wildcard-selector-composer-v2-modal.sidebar-animating-out > .textbox {
    width: 100%;
    transition: width var(--wc-modal-animation-duration-long) ease var(--wc-modal-animation-duration);
}

#wildcard-selector-composer-v2-overlay.closing:not(.sidebar-hidden) {
    animation: fadeOut var(--wc-modal-animation-duration) ease calc(var(--wc-modal-animation-duration) * 1.33) forwards;
}

#wildcard-selector-composer-v2-modal.closing:not(.sidebar-hidden) .textbox {
    opacity: 1;
    animation: fadeOut var(--wc-modal-animation-duration) var(--wc-modal-animation-timing) var(--wc-modal-animation-duration) forwards;
}

#wildcard-selector-composer-v2-modal.closing:not(.sidebar-hidden) .sidebar {
    animation: shrinkWidth var(--wc-modal-animation-duration) var(--wc-modal-animation-timing) forwards;
}

#wildcard-selector-composer-v2-overlay.closing.sidebar-hidden {
    animation: fadeOut var(--wc-modal-animation-duration) ease forwards;
}

#wildcard-selector-composer-v2-modal.closing.sidebar-hidden .textbox {
    animation: fadeOut var(--wc-modal-animation-duration) ease forwards;
}

#wildcard-selector-composer-v2-modal.closing.sidebar-hidden .sidebar {
    animation: none;
}

.textbox-action-bar {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: none;
    justify-content: flex-end;
}

.textbox-action-btn {
    padding: 0.5rem 1.2rem;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    background: #232323;
    color: #e0e0e0;
    box-shadow: 0 2px 6px 0 rgba(0,0,0,0.12);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.textbox-action-btn.clear:hover {
    background: #b71c1c;
    color: #ffcdd2;
}

.textbox-action-btn.save:hover {
    background: #1b5e20;
    color: #c8e6c9;
}

.textbox-content {
    flex: 1 1 auto;
    margin: 0.5rem 1rem;
    background: #232323;
    color: #cccccc;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    padding: 0.25rem;
    box-sizing: border-box;
    outline: none;
    display: block;
    height: 100%;
    min-height: 0;
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.08), inset 2px 2px 6px rgba(0, 0, 0, 0.2); /* Inward shadows */
}

.textbox, .textbox-content, .CodeMirror {
    height: 100%;
    min-height: 0;
}

.CodeMirror-selectedtext {
    background: #444 !important;
}

.option-mark {
    background-color: #444444 !important;
}

.wildcard-mark {
    background-color: #444444 !important;
}

.CodeMirror .CodeMirror-selected {
  display: none !important;
}

.CodeMirror {
    background: #232323 !important;
    color: #cccccc !important;
    font-size: 1rem !important;
    font-family: inherit !important;
    height: 100% !important;
    min-height: 0 !important;
    padding: 0.5rem; /* Retain padding for spacing */
    box-sizing: border-box; /* Ensure padding doesn't affect dimensions */
}

.cm-comment {
    color: #666666 !important;
}

.CodeMirror-cursor {
    border-left: 1px solid #cccccc !important;
}

.sidebar-dropdowns-scroll {
    flex: 1 1 auto;
    height: calc(100% - 2.5rem);
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.sidebar-dropdowns-scroll > .wildcard-dropdown-container {
    width: 95%;
    margin: 0 auto 8px auto;
}

.sidebar-dropdowns-scroll > .wildcard-dropdown-container:first-child {
    margin-top: 0.5rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes growWidth {
    from {
        width: 0%;
        transform: scaleX(0);
    }
    to {
        width: var(--wc-modal-sidebar-width);
        transform: scaleX(1);
    }
}

@keyframes shrinkWidth {
    from {
        width: var(--wc-modal-sidebar-width);
        transform: scaleX(1);
    }
    to {
        width: 0%;
        transform: scaleX(0);
    }
}

.custom-dropdown-options {
    position: static;
    width: 100%;
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    overflow: hidden;
    transition: max-height 0.25s cubic-bezier(.25,.8,.25,1), opacity 0.2s;
}

.custom-dropdown.open .custom-dropdown-options {
    max-height: 200px;
    opacity: 1;
    visibility: visible;
    overflow-y: auto;
}

.custom-dropdown-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #ccc;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-dropdown.open .custom-dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.custom-dropdown-option {
    width: 100%;
    height: 40px;
    line-height: 40px;
    padding: 0 12px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    color: #ccc;
    border: none;
    font-size: 0.9em;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    box-sizing: border-box;
    display: block;
    background: rgba(40, 40, 40, 0.92);
}

.custom-dropdown-option:hover {
    background: rgb(30, 30, 30);
}

.custom-dropdown-option.not-selected {
    color: #999;
    font-style: italic;
}

.custom-dropdown-button,
.custom-dropdown-option {
    padding-right: 40px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.custom-dropdown-button {
    display: flex;
    align-items: center;
    width: 100%;
    height: 40px;
    padding-left: 8px;
    padding-right: 0;
    background: rgba(20, 20, 20, 0.98);
    color: #ccc;
    border: none;
    font-size: 0.9em;
    cursor: pointer;
    text-align: left;
    position: relative;
    transition: background-color 0.2s, color 0.2s;
    overflow: hidden;
    white-space: nowrap;
}

.custom-dropdown-text {
    flex: 1 1 0%;
    min-width: 0;
    margin-right: 40px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}


.custom-dropdown-options::-webkit-scrollbar {
    display: none;
}

.custom-dropdown-options {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.wildcard-dropdown-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    position: relative;
}


.custom-dropdown-button:hover,
.custom-dropdown-button:focus {
    background: rgba(30, 30, 30, 0.98);
    outline: none;
}

.custom-dropdown .custom-dropdown-button {
    background: rgba(20, 20, 20, 0.98);
    color: #ccc;
}

.sidebar-apply-btn {
    position: absolute;
    left: 70%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 0.4rem 2.4rem;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    background: #232323;
    color: #e0e0e0;
    box-shadow: 0 2px 6px 0 rgba(0,0,0,0.12);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    height: 1.7rem;
}

.sidebar-apply-btn:hover {
    background: #1b5e20;
    color: #c8e6c9;
}

.comment-highlight {
    color: #888 !important;
}

/* --- Custom Context Menu for Textbox --- */
.textbox-context-menu {
    position: fixed;
    z-index: 99999;
    background: #1E1E1E;
    border: none;
    box-shadow: 2px 4px 4px 0 rgba(0, 0, 0, 0.40);
    padding: 4px 0;
    min-width: 120px;
    font-size: 0.8em;
    left: var(--menu-left, 0px);
    top: var(--menu-top, 0px);
    visibility: hidden;
    pointer-events: none;
    display: block;
}

.textbox-context-menu-item {
    padding: 8px 20px;
    cursor: pointer;
    color: #fff;
    background: #1E1E1E;
    border: none;
    margin: 0;
    transition: background 0.2s ease, color 0.2s ease;
    opacity: 1;
}

.textbox-context-menu-item:hover {
    background: #333;
    color: #fff;
}

.textbox-context-menu-separator {
    height: 1px;
    background: #444;
    margin: 4px 0;
}

.textbox-context-menu-item.disabled {
    opacity: 0.5; /* Visual indication of being disabled */
    cursor: auto;
}